
package com.lk.lkappearance.controller;

import com.lk.lkappearance.common.AbstractBaseController;
import com.lk.lkappearance.model.Dictionary;
import com.lk.lkappearance.service.DictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/api/dict")
public class DictionaryController extends AbstractBaseController {

    @Autowired
    private DictionaryService dictionaryService;

    /**
     *
     * @param dictionary
     * @return
     */
    @RequestMapping(value = "/getList", method = RequestMethod.GET)
    public Map<String,Object> getList(@RequestBody Dictionary dictionary){
        log.info("根据条件查询全部字典");
        return dictionaryService.getList(dictionary);
    }

    /**
     *
     * @param dictionary
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Map<String,Object> add(@RequestBody Dictionary dictionary){
        log.info("添加字典");
        return dictionaryService.add(dictionary);
    }

    /**
     *
     * @param dictionary
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Map<String,Object> update(@RequestBody Dictionary dictionary){
        log.info("修改字典");
        return dictionaryService.modify(dictionary);
    }

    /**
     *
     * @param dictionaryId
     * @return
     */
    @RequestMapping(value = "/del", method = RequestMethod.POST)
    public Map<String,Object> delete(@RequestBody String dictionaryId){
        log.info("根据主键删除字典");
        return dictionaryService.delete(dictionaryId);
    }

    /**
     *
     * @param dictionary
     * @return
     */
    @RequestMapping(value = "/exportExcel", method = RequestMethod.GET)
    public Map<String,Object> getListExcel(@RequestBody Dictionary dictionary){
        log.info("导出");
        return dictionaryService.getList(dictionary);
    }

    /**
     *
     * @param dictionaryList
     * @return
     */
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Map<String,Object> insertList(@RequestBody List<Dictionary> dictionaryList){
        log.info("导入");
        return dictionaryService.insertList(dictionaryList);
    }

}
